<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>权限管理</title>
<script type="text/javascript"src="../static/jquery-easyui-1.5.5.3/jquery.min.js"></script>
<link rel="stylesheet"href="../static/jquery-easyui-1.5.5.3/themes/default/easyui.css" />
<link rel="stylesheet"href="../static/jquery-easyui-1.5.5.3/themes/icon.css" />
<script type="text/javascript"src="../static/jquery-easyui-1.5.5.3/jquery.easyui.min.js"></script>
<script type="text/javascript"src="../static/jquery-easyui-1.5.5.3/locale/easyui-lang-zh_CN.js"></script>
</head>
<body>

<table id="permission_table"></table>

<script type="text/javascript">
	$(function(){
		$('#permission_table').datagrid({
			idField:'id', 
			title:'权限列表',
			width:'100%',
			fitColumns: true,
			striped:true, //隔行变色
			url:'page', //异步加载数据路径
			loadMsg: '数据正在加载...请耐心等待....', //在从远程站点加载数据的时候显示提示消息
			rownumbers: true, //在表格前面显示行号
			nowrap:true, //折行显示
			singleSelect:true, //只允许选中一行
			remoteSort:false, //取消本地排序
			pagination:true, //设置分页
			pageSize:10, //设置开始显示几条数据
			pageList:[10,20,25,50],//设置分页条数
			columns:[
				[	
					{field:'name',title:'权限名称',width:'50%',align:'center'},
					{field:'code',title:'代码',width:'50%',align:'center'}
				]
			],
			toolbar:[
				{
					text:'新增',
					iconCls:'icon-add', //小图标
					handler:function(){
						$('#mydialog').dialog({ //动态生成表头
							title:'新增',
						 });
						$('#mydialog').dialog('open');
					}
				}
			]
		});	 
		
		//提交表单方法
		$('#btn1').click(function(){
			if($('#myform').form('validate')){
				$.ajax({
					type:'post',
					url:'save', 
					cache:false, 
					data:$('#myform').serialize(), 
					success:function(result){
						$('#mydialog').dialog('close');
						$('#permission_table').datagrid('reload');
						$.messager.show({
							title:'提示信息!',
							msg:'操作成功！',
							height:180,
							width:220
						});
					}
				});
			}else{
				$.messager.show({
					title:'提示信息!',
					msg:'数据验证不通过，不能保存！'
				})
			}	
		});
	});
</script>
	<div id="mydialog" class="easyui-dialog" style="width:250px;" closed=true modal=true draggable=false title="新增学院">
		<form id ="myform" action="" method="post">
			<input type="hidden" name="id" value=""/>
			<table class="input_container">
				<tr>
					<td>
						<label for="collegename">权限名称</label>
					</td>
					<td>
						<input type="text" class="easyui-validatebox easyui-textbox" name="name" id="collegename" required=true validType="isBlank" missingMessage="学院名必填" style="width: 170px;">
					</td>
				</tr>
				<tr>
					<td>
						<label for="principal">代码</label>
					</td>
					<td>
						<input type="text"name="code" id="principal" class="easyui-validatebox easyui-textbox" required=true validType="isBlank" missingMessage="负责人姓名必填！" style="width: 170px;">
					</td>
				</tr>
				<tr style="text-align:right;">
					<td colspan="2">
						<a class="easyui-linkbutton" id="btn1" iconCls='icon-save'>确定</a>
						<a class="easyui-linkbutton" id="btn2" iconCls='icon-undo'>关闭</a>
					</td>
				</tr>
			</table>			
		</form>
	</div>
</body>
</html>